home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / lib / perl5 / oose.pm < prev    next >
Encoding:
Perl POD Document  |  2010-07-25  |  2.0 KB  |  91 lines

  1. package oose;
  2.  
  3. use strict;
  4. use warnings;
  5.  
  6. use Class::MOP;
  7.  
  8. our $VERSION   = '1.09';
  9. $VERSION = eval $VERSION;
  10. our $AUTHORITY = 'cpan:STEVAN';
  11.  
  12. BEGIN {
  13.     my $package;
  14.     sub import {
  15.         $package = $_[1] || 'Class';
  16.         if ($package =~ /^\+/) {
  17.             $package =~ s/^\+//;
  18.             Class::MOP::load_class($package);
  19.         }
  20.     }
  21.     use Filter::Simple sub { s/^/package $package;\nuse Moose;use Moose::Util::TypeConstraints;\n/; }
  22. }
  23.  
  24. 1;
  25.  
  26. __END__
  27.  
  28. =pod
  29.  
  30. =head1 NAME
  31.  
  32. oose - syntactic sugar to make Moose one-liners easier
  33.  
  34. =head1 SYNOPSIS
  35.  
  36.   # create a Moose class on the fly ...
  37.   perl -Moose=Foo -e 'has bar => ( is=>q[ro], default => q[baz] ); print Foo->new->bar' # prints baz
  38.  
  39.   # loads an existing class (Moose or non-Moose)
  40.   # and re-"opens" the package definition to make
  41.   # debugging/introspection easier
  42.   perl -Moose=+My::Class -e 'print join ", " => __PACKAGE__->meta->get_method_list'
  43.  
  44.   # also loads Moose::Util::TypeConstraints to allow subtypes etc
  45.   perl -Moose=Person -e'subtype q[ValidAge] => as q[Int] => where { $_ > 0 && $_ < 78 }; has => age ( isa => q[ValidAge], is => q[ro]); Person->new(age => 90)'
  46.  
  47. =head1 DESCRIPTION
  48.  
  49. oose.pm is a simple source filter that adds C<package $name; use Moose;>
  50. to the beginning of your script and was entirely created because typing
  51. C<perl -e'package Foo; use Moose; ...'> was annoying me.
  52.  
  53. =head1 INTERFACE
  54.  
  55. oose provides exactly one method and it's automatically called by perl:
  56.  
  57. =over 4
  58.  
  59. =item B<import($package)>
  60.  
  61. Pass a package name to import to be used by the source filter.
  62.  
  63. =back
  64.  
  65. =head1 DEPENDENCIES
  66.  
  67. You will need L<Filter::Simple> and eventually L<Moose>
  68.  
  69. =head1 INCOMPATIBILITIES
  70.  
  71. None reported. But it is a source filter and might have issues there.
  72.  
  73. =head1 BUGS
  74.  
  75. See L<Moose/BUGS> for details on reporting bugs.
  76.  
  77. =head1 AUTHOR
  78.  
  79. Chris Prather  C<< <chris@prather.org> >>
  80.  
  81. =head1 COPYRIGHT AND LICENSE
  82.  
  83. Copyright 2007-2009 by Infinity Interactive, Inc.
  84.  
  85. L<http://www.iinteractive.com>
  86.  
  87. This library is free software; you can redistribute it and/or modify
  88. it under the same terms as Perl itself.
  89.  
  90. =cut
  91.